/**
 * @author: gao
 * @create-date: 2025/3/7 22:50
 */

public class Sort {
    public void ShellSort(int[] array) {
        int gap = array.length / 2;
        while (gap > 0) {
            Shell(array, gap);
            gap /= 2;
        }
    }

    public void Shell(int[] array, int gap) {
        for (int i = gap; i < array.length; i++) {
            int tmp = array[i];
            int j = i - gap;
            for (; j >= 0; j-= gap) {
                if (array[j] > tmp) {
                    array[j + gap] = array[j];
                } else {

                    break;
                }
            }

            array[j + gap] = tmp;
        }
    }
}